/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package net.tygzs.minerpg.timer;

import net.tygzs.minerpg.Main;
import net.tygzs.minerpg.event.MineRPGTimeChangeEvent;
import org.bukkit.Bukkit;

/**
 *
 * @author thtTNT
 */
public class Timer
{

    private long ServerTime;

    public Timer()
    {
        Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(), new Runnable()
        {

            @Override
            public void run()
            {
                Main.getPluginConfig().getTimer().passTime();
                MineRPGTimeChangeEvent event = new MineRPGTimeChangeEvent(Main.getPluginConfig().getTimer().ServerTime);
                Bukkit.getPluginManager().callEvent(event);
            }
        }, 0L, 20L);
    }

    public long getServerTime()
    {
        return this.ServerTime;
    }

    public Timer(long time)
    {
        this.ServerTime = time;
    }

    public void passTime()
    {
        this.ServerTime++;
    }
}
